package com.test.prolenders.dialog_prolenders;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.test.prolenders.R;


public class KindTipDialog_prolenders extends Dialog {

    private final Runnable denyRunnable,agreeRunnable;

    public KindTipDialog_prolenders(@NonNull Context context, Runnable denyRunnable, Runnable agreeRunnable) {
        super(context);
        this.denyRunnable = denyRunnable;
        this.agreeRunnable = agreeRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_kind_tip_prolenders);
        initView();
    }

    @SuppressLint("SetTextI18n")
    private void initView(){

        getWindow().setBackgroundDrawableResource(R.color.transparent_prolenders);
        setCanceledOnTouchOutside(false);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        View denyBtn = findViewById(R.id.dkt_btn_deny);

        if (denyRunnable == null) denyBtn.setVisibility(View.GONE);

        denyBtn.setOnClickListener(v -> {
            dismiss();
            if (denyRunnable != null) denyRunnable.run();
        });

        findViewById(R.id.dkt_btn_agree).setOnClickListener(v -> {
            dismiss();
            if (agreeRunnable!=null) agreeRunnable.run();
        });

    }

}
